$(document).ready(function(){
	//ajax分页调用函数
	function fPagingAjax(pageNum,pageSize){
		$.ajax({
		   	type: "post",
		   	dataType: "json",
		   	url: "/Handler/AuthorityCenterHandler.ashx",
		   	data: {
		   		fun: "f_0008",
		   		data: pageNum,
		   		pageSize: pageSize
		   	},
		   	success: function(msg) {
		   		if(msg.r_code==="1"){
		   			$("table.sortable .grid-pages").html(msg.p_sum);
		   			$("table.sortable .grid-count").html(msg.p_count);
		   			$("table.sortable tbody").empty();
		   			fCreateTable(msg);
		   		}
		   	}
		});
	};
	//分页查询
	/*$.ajax({
		type: "post",
		dataType: "json",
		url: "/Handler/AuthorityCenterHandler.ashx",
		data: {
			fun: "f_0008",
			data:"1",
			pageSize:"10"
		},
		success: function(msg) {
			if(msg.r_code==="1"){
				$("table.sortable").removeClass("hide");
				fCreateTable(msg);
				//引用分页插件
				$('table.sortable tfoot').bootpag({
				    total: msg.p_sum,//总页数
				    gridPages: msg.p_sum,//总页数
				    gridCount: msg.p_count,//总条数
				}).on("page", function(event, pageNum, pageSize){
				   //分页点击事件
				   fPagingAjax(pageNum, pageSize);
				});
			}
		}
	});*/
	//单个删除
	$(".btndelete").on("click", function() {
	    var $this = $(this);
	    bootbox.confirm("<h3>确定要删除此项?</h3>", "取消", "确定", function(result) {
	        if (result) {
	            $.ajax({
	                url: "/Handler/ProductHandler.ashx",
	                type: "post",
	                dataType: "json",
	                data: {
	                    fun: "f_0003",
	                    id: $this.attr("val")
	                },
	                beforeSend: function () {
	                    //数据加载冻屏
	                    $this.button('loading');
	                },
	                success: function (msg) {
	                    //数据加载完毕解除冻屏
	                    $this.button('reset');
	                    if (msg.r_code == "1") {
	                        toastr.success(msg.r_info,'系统提示：');
	                        //刷新页面
	                        setTimeout(function () {
                                window.location.href = window.location.href;
                            }, 1000);
	                    } else if (msg.r_code == "0") {
	                        toastr.error(msg.r_info,'错误提示：');
	                    }
	                }
	            });
	        }else{
	            $(this).modal("hide");
	        };
	    });
	});
});
